package NewCode;

import java.util.Arrays;
import java.util.OptionalInt;

/**
 * @author wangchenghao
 * @date 2021/7/22
 **/
public class NC30 {
    public static int minNumberdisappered (int[] arr) {
        // write code here
        Arrays.stream(arr).sorted();
        int min =Arrays.stream(arr).min().getAsInt();
        int max = Arrays.stream(arr).max().getAsInt();
        int sum1=(min+max)*(max-min)/2;
        int sum2=0;
        for (int i : arr) {
            sum2+=i;
        }
        return Math.max(1,sum1-sum2);

    }

    public static void main(String[] args) {
        minNumberdisappered(new int[]{-1,2,3,4});
    }

}
